package com.ftg.shopping.person.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;


import com.ftg.shopping.person.entity.sp_personinfo;
import org.apache.ibatis.annotations.*;


import java.util.List;
import java.util.Map;


@Mapper
public interface personMapper  extends BaseMapper<sp_personinfo>{

    @Update("update sp_personinfo set personname=#{personname},idnumber=#{idnumber},deptno=#{deptno},position=#{position},tel=#{tel},sex=#{sex},servicedate=#{servicedate},education=#{education},nation=#{nation},personstatus=#{personstatus},photourl=#{photourl},salary=#{salary},remark=#{remark} where personid=#{personid}")
    int updateperson(sp_personinfo sp);



    @Insert("insert into sp_personinfo(personid,personname,idnumber,deptno,position,tel,sex,servicedate,education,nation,personstatus,photourl,salary,remark) values (#{personid},#{personname},#{idnumber},#{deptno},#{position},#{tel},#{sex},#{servicedate},#{education},#{nation},#{personstatus},#{photourl},#{salary},#{remark})")
    int insertperson(String upload,sp_personinfo sp);

    @Delete("delete from sp_personinfo where personid=#{personid}")
    int deleteperson(int personid);

    @Select("SELECT c.userid,personid,personname,b.dname,position,tel,sex,education FROM sp_personinfo a LEFT JOIN sp_deptinfo b ON a.deptno=b.deptno " +
            "               LEFT JOIN sp_userinfo c ON a.personid = c.userid  where personname=#{personname} limit #{page},#{limit}")
    List<Map<String,Object>> findone(int page,int limit,String personname);

    @Select("SELECT c.userid,personid,personname,b.dname,position,tel,sex,education FROM sp_personinfo a LEFT JOIN sp_deptinfo b ON a.deptno=b.deptno " +
            "               LEFT JOIN sp_userinfo c ON a.personid = c.userid limit #{page},#{limit}")
    List<Map<String,Object>> showperson(int page,int limit);

    @Select("SELECT c.userid,personid,personname,b.dname,position,tel,sex,education FROM sp_personinfo a LEFT JOIN sp_deptinfo b ON a.deptno=b.deptno " +
            "               LEFT JOIN sp_userinfo c ON a.personid = c.userid ")
    List<Map<String,Object>> showperson2();
}
